//
//  商品品论Cell.swift
//  Aiwei
//
//  Created by zhu xietong on 2017/11/13.
//  Copyright © 2017年 zhu xietong. All rights reserved.
//

import Foundation
import Eelay
import soapp

extension MallForm{
    
    public class GoodsCommentCell<Line:LineHeight>: FieldCell {
        
        public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
            iconV.image = UIImage(named:"kf_ts")?.rt_tintedImage(with: .color(light: "#999", dark: "#444"))
        }
        
        public var textV = TextAreaField()
        public let iconV = UIImageView()
        public override func addLayoutRules() {
            //        let w = Int(FieldCell.name_width)
            //        let t = Int(FieldCell.padding_top)
            //        let b = Int(FieldCell.padding_bottom)
            let l = Int(FieldCell.padding_left)
            
            contentView.eelay = [
                [titleL,[ee.T.L,[8,l]],"21",21],
                [requiredMark,[titleL,ee.Y,3],[titleL,ee.R,ee.L,2]],
                [__line,[ee.L.B.R,[0,0.0]],"0.5"]
            ]
            contentView.eelay = [
                [iconV,[ee.T.L,[8,l]],"21",21],
                [textV,[iconV,ee.R,ee.L,2],[ee.R,-AppTheme.edge],[iconV,ee.T,-7],"\(Line.height)",[ee.B,-8]],
            ]
            textV.backgroundColor = ._cellBackground
            self.indicator = .none
            iconV.image = UIImage(named:"kf_ts")?.rt_tintedImage(with: .color(light: "#999", dark: "#444"))
        }
        
        public override func mo_model_reload() {
            //        contentView.fillData(model: mo.model)
            
            if let f = DataNode<NSMutableDictionary>.path(node: "\(FK.field)", mo.model)
            {
                textV.mo.model = f
            }
            else
            {
                if let f = DataNode<NSMutableDictionary>.path(node: "\(FK.fields).0", mo.model)
                {
                    textV.mo.model = f
                }
            }
            //        textV.valueT.bsui.background(color: _table_bk_color)
        }
        
    }

}
